{include file="common/header.tpl"}
<script language="javascript">
{literal}
	function UpdateImage(img, val, target)
	{
		elm = window.parent.document.getElementById(target);
		elm.value = val;
	}
	
	function resizeClick()
	{
		if($('resize').checked)
		{
			$('w').disabled = '';
			$('h').disabled = '';
		}
		else
		{
			$('w').disabled = 'disabled';
			$('h').disabled = 'disabled';
		}
	}
{/literal}
</script>
<body topmargin="0px">
{* Check which item is currently active and set active tab to it*}
{if $smarty.get.mod eq "browseall"}
	{assign var="browseall" value="current"}
{elseif $smarty.get.mod eq "browse"}
	{assign var="browse" value="current"}
{else}
	{assign var="upload" value="current"}
{/if}
{if $smarty.session.u_isadmin == "1"}
<div class="uploadtab" id="tabs4" style=" padding:0; margin: 0;">
	<ul id="tab4list" style=" padding: 4px 0 0 0; margin: 0;">
		<li id="{$upload}"><a href="?mod=upload&target={$smarty.get.target}&modfile={$smarty.get.modfile}"><span>{t}Upload{/t}</span></a></li>
		{if $smarty.session.product != null || $smarty.session.partner != null}
		<li id="{$browse}"><a href="?mod=browse&target={$smarty.get.target}&modfile={$smarty.get.modfile}"><span>{t}Browse{/t}</span></a></li>
		{/if}
		<!--<li id="{$browseall}"><a href="?mod=browseall&target={$smarty.get.target}"><span>{t}Browse All{/t}</span></a></li>-->
	</ul>
</div>

{if $smarty.get.mod eq "browse"}
	{* ------------------- Browse panel ---------------------------  *}
	<div class="upload_pane" id="pane1">
		{if $smarty.session.type != "pdf"}
			{foreach name=image from=$smarty.session.file item=product}
				<img id="{$product}" src="../includes/thumb.php?src={$product}" 
				onclick="UpdateImage(this, '{$product}', '{$smarty.get.target}')"/>
			{/foreach}
		{else}
			{foreach name=image from=$smarty.session.file item=product}
				<a id="{$product}" onClick="UpdateImage(this, '{$product}', '{$smarty.get.target}')">{$smarty.session.name}
				</a>
			{/foreach}
		{/if}
	</div>    
{else}
	{* ------------------- Upload panel ---------------------------  *}
	<div class="upload_pane" id="pane0">
		{if $error_msg != null}
			{if $error != 0}	
				<div id="msg" class="fade" style="color:red;display:inline;">{$error_msg}</div>
			{else}
				<div id="msg" class="fade" style="color:blue;display:inline;">{$error_msg}</div>
			{/if}
		{/if}

		<form enctype="multipart/form-data" action="" method="POST">
		    <input type="hidden" name="mod" value="{$smarty.get.modfile}" />
		    <!-- Name of input element determines name in $_FILES array -->
		   <input size="50" name="userfile" type="file" />
		    <br />
		    <p class="submit" align = "right">
		    <input type="submit" value="{t}Upload File{/t}" />
		    </p>
		</form>
	</div>
{/if}
{/if}
</body>
</html>